package com.mall.controller;

import com.mall.domain.ItemGoods;
import com.mall.domain.ListSeacher;
import com.mall.service.IItemGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("goods")
public class ItemGoodsController {

    @Autowired
    private IItemGoodsService itemGoodsService;

    @RequestMapping("/search")
    public @ResponseBody
    Map<String, Object> test(ListSeacher listSeacher) {
        System.out.println(listSeacher);
        Map<String, Object> map = new HashMap<>();
        Map<String, Object> msgMap = new HashMap<>();
        msgMap.put("total",listSeacher.getPagesize());
        msgMap.put("pagenum",listSeacher.getPagenum());
        List<ItemGoods> itemGoods = itemGoodsService.findListGoods(listSeacher);
        msgMap.put("goods",itemGoods);
        Map<String, Object> metaMap = new HashMap<>();
        metaMap.put("code",200);
        metaMap.put("msg","查询成功");
        map.put("message",msgMap);
        map.put("meta",metaMap);
        return map;
    }
}
